{include file="common/header"/}
<style> .layui-iconpicker-body.layui-iconpicker-body-page .hide {display: none;}</style>
<div class="lemo-container">
    <div class="lemo-main">
        <div class="admin-main layui-anim layui-anim-upbit">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>{:lang('add')}/{:lang('edit')}</legend>
            </fieldset>
            <form class="layui-form layui-form-pane" lay-filter="form">
                <div class="layui-form-item">
                    <label class="layui-form-label">事件名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" lay-verify="required" placeholder="请输入事件名称"   class="layui-input">
                    </div>
                </div>
				
				<!-- <div class="layui-form-item">
				    <label class="layui-form-label">渠道负责人</label>
				    <div class="layui-input-inline">
				        <input type="text" name="charge" lay-verify="required" placeholder="请输入渠道负责人"   class="layui-input">
				    </div>
				</div>
				<div class="layui-form-item">
				    <label class="layui-form-label">手机号</label>
				    <div class="layui-input-inline">
				        <input type="number" name="mobile" min="0" step="1" lay-verify="required" placeholder="请输入手机号"   class="layui-input">
				    </div>
				</div> -->
                <div class="layui-form-item">
					<input type="hidden" name="id">
                    <div class="layui-input-inline">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">立即提交</button>
                        <a data-href="{:url('index')}" class="layui-btn layui-btn-primary back">返回</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

{include file="common/footer"/}
<script>
    layui.config({
        base: '/static/admin/js/'
    }).use(['form', 'layer','Admin'], function () {
        var form = layui.form,layer = layui.layer,$= layui.jquery;
        var info  = {:json_encode($info)};
        var url = "{:url('add')}";
        if(info){
            form.val('form',info);
            url = "{:url('edit')}";
            // $('#addPic').attr('src',info.icon);
        }
        // $(function(){
        //     $(".copy").click(function () {
        //         $("#lisp").append($("#need_clone").clone(true));
        //         form.render();
        //     });
        //     $(".delete").click(function () {
        //         if($("select[name='service_id[]").length == 1){
        //             layer.msg('最少添加1个');
        //             return false;
        //         }
        //         $(this).parent().parent().remove();
        //     });
        // });
        //返回页面
        $('body').on('click','.back',function() {
            var url = $(this).attr('data-href');
            layer.closeAll();
            window.parent.location.href=url;
        });
        form.on('submit(submit)', function (data) {
            // 提交到方法 默认为本身
            if(data.field.icon=='fa undefined'){
                data.field.icon = icon;
            }
            $.post(url,data.field,function(res){
                if(res.code > 0){
                    layer.msg(res.msg,{time:1000,icon:1},function(){
                        layer.closeAll();
                        window.parent.location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            });
        })
    });
</script>
